// import { createRouter, createWebHashHistory } from 'vue-router'

// const routes = [
//   {
//     path: '/',
//     name: 'layout',
//     component: () => import('@/views/layout/index.vue'),
//     children: [
//       {
//         path: '/',
//         component: () => {
//           '@/views/home/index.vue'
//         }
//       }
//     ]
//   },
//   {
//     path: '/login',
//     name: 'login',
//     component: () => import('@/views/login/index.vue')
//   }
// ]

// const router = createRouter({
//   history: createWebHashHistory(),
//   routes
// })
// export default router

import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/views/layout/index.vue')
const Login = () => import('@/views/login/index.vue')
const Home = () => import('@/views/home/index.vue')
const TopCategory = () => import('@/views/category/index.vue')
const SubCategory = () => import('@/views/category/sub.vue')
const Goods = () => import('@/views/goods/index')

const routes = [
  // 主页
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: SubCategory },
      { path: '/product/:id', component: Goods }
    ]
  },
  // 登录页
  {
    path: '/login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior() {
    return { left: 0, top: 0 }
  }
})

export default router
